package org.minos.edit.view.components
{
	import flash.events.Event;
	import org.aswing.ASColor;
	import org.aswing.BorderLayout;
	import org.aswing.Component;
	import org.aswing.ext.Form;
	import org.aswing.FlowLayout;
	import org.aswing.JButton;
	import org.aswing.JComboBox;
	import org.aswing.JLabel;
	import org.aswing.JLabelButton;
	import org.aswing.JPanel;
	import org.aswing.JTextArea;
	import org.aswing.JTextField;
	import org.aswing.SoftBoxLayout;
	
	/**
	 * ...
	 * @author Minos
	 */
	public class CreateScenePane extends JPanel
	{
		private var labelTf : JTextField;
		private var frameTf : JTextField;
		private var typeCb : JComboBox;
		private var childrenTf : JTextField;
		private var childrenBtn : JButton;
		private var urlTf : JTextField;
		private var urlBtn : JButton;
		private var scoreTf : JTextField;
		private var scoreBtn : JButton;
		private var tooltipTf : JTextField;
		private var infoTf : JTextField;
		private var okButton : JButton;
		private var cancelButton : JButton;
		private var continueInfoTa : JTextArea;
		private var endInfoTa : JTextArea;
		
		private var form : Form;
		private var label : String;
		private var frame : String;
		
		public function CreateScenePane( label : String = "场景" , frame : String = "0" )
		{
			super();
			this.frame = frame;
			this.label = label;
			init();
		}
		
		/**
		 *
		 */
		private function init() : void
		{
			
			setLayout( new BorderLayout() );
			form = new Form();
			append( form , BorderLayout.CENTER );
			
			labelTf = new JTextField( label , 15 );
			frameTf = new JTextField( frame , 4 );
			frameTf.setRestrict( "0123456789" );
			typeCb = new JComboBox([ "普通" , "胜利" , "失败" ] );
			childrenTf = new JTextField( "" , 15 );
			childrenBtn = new JButton( "设置子菜单" );
			urlTf = new JTextField( "*.swf" , 12 );
			urlBtn = new JButton( "选择动画" );
			scoreTf = new JTextField( "0" , 15 );
			scoreBtn = new JButton( "设置得分" );
			scoreBtn.setEnabled( false );
			scoreTf.setRestrict( "0123456789," );
			
			tooltipTf = new JTextField( "鼠标提示" , 12 );
			infoTf = new JTextField( "操作提示" , 12 );
			
			continueInfoTa = new JTextArea( "" , 3 , 20 );
			continueInfoTa.setWordWrap( true );
			endInfoTa = new JTextArea( "" , 3 , 20 );
			endInfoTa.setWordWrap( true );
			
			okButton = new JButton( "确定" );
			cancelButton = new JButton( "取消" );
			
			form.addSpacer();
			
			addLabelRow( labelTf , "场景名称: " , "eg: 胜利" );
			addLabelRow( frameTf , "图标帧数: " , "(图标影片的帧数) eg: 1" );
			addLabelRow( typeCb , "场景类型: " , "" );
			addLabelRow( childrenTf , "子菜单: " , "(子选项) eg: 向左,向右,向前" , childrenBtn );
			addLabelRow( urlTf , "动画路径: " , "(播放的动画) eg: *.swf" , urlBtn );
			addLabelRow( scoreTf , "得分: " , "eg: 30,20,0" , scoreBtn );
			addLabelRow( tooltipTf , "鼠标提示: " , "eg: 向左" );
			addLabelRow( infoTf , "操作提示: " , "eg: 你有三条路，要走哪条?" );
			addLabelRow( continueInfoTa , "选项评语: " , "eg: 选择这条路是正确的，#&@.." );
			addLabelRow( endInfoTa , "结束评语: " , "eg: 是正确的，#*(@.." );
			
			form.addSpacer();
			form.addSeparator();
			
			var buttonPane : JPanel = new JPanel( new FlowLayout( FlowLayout.CENTER , 16 , 5 ) );
			buttonPane.appendAll( okButton , cancelButton );
			form.append( buttonPane );
			
			typeCb.addActionListener( __typeCbSelectChanged );
		}
		
		private function __typeCbSelectChanged( e : Event ) : void
		{
			var boo : Boolean = ( typeCb.getSelectedIndex() == 0 ) ? true : false;
			childrenTf.setEnabled( boo );
			childrenBtn.setEnabled( boo );
		}
		
		/**
		 *
		 * @param	c
		 * @param	text
		 * @param	toolTip
		 * @param	act
		 */
		private function addLabelRow( c : Component , text : String , toolTip : String = null , act : Component = null ) : void
		{
			var label : JLabel = new JLabel( text , null , JLabel.LEFT );
			var tip : JLabel = null;
			if ( toolTip )
			{
				tip = new JLabel( toolTip , null , JLabel.LEFT );
				tip.setForeground( ASColor.GRAY );
			}
			form.addRow( label , c , act , tip );
		}
		
		// ----- get ----- //
		
		/**
		 *
		 * @return
		 */
		public function getLabelTf() : JTextField
		{
			return labelTf;
		}
		
		public function getFrameTf() : JTextField
		{
			return frameTf;
		}
		
		public function getTypeCombox() : JComboBox
		{
			return typeCb;
		}
		
		public function getChildrenTf() : JTextField
		{
			return childrenTf;
		}
		
		public function getChildrenBtn() : JButton
		{
			return childrenBtn;
		}
		
		public function getUrlTf() : JTextField
		{
			return urlTf;
		}
		
		public function getUrlBtn() : JButton
		{
			return urlBtn;
		}
		
		public function getScoreTf() : JTextField
		{
			return scoreTf;
		}
		
		public function getScoreBtn() : JButton
		{
			return scoreBtn;
		}
		
		public function getTooltipTf() : JTextField
		{
			return tooltipTf;
		}
		
		public function getInfoTf() : JTextField
		{
			return infoTf;
		}
		
		public function getContinueInfoTa() : JTextArea
		{
			return continueInfoTa;
		}
		
		public function getEndInfoTa() : JTextArea
		{
			return endInfoTa;
		}
		
		public function getOkButton() : JButton
		{
			return okButton;
		}
		
		public function getCancelButton() : JButton
		{
			return cancelButton;
		}
	
	}

}